package com.youyoulong.framework.util;

import java.util.LinkedHashMap;
import java.util.Map;

import com.youyoulong.framework.util.beans.SystemConfigBean;

public final class SystemConfigUtil
{
    private LinkedHashMap<String, Object> configs;
    
    // public LinkedHashMap<String, Object> getConfigs()
    // {
    // return configs;
    // }
    //
    // public void setConfigs(LinkedHashMap<String, Object> configs)
    // {
    // this.configs = configs;
    // }
    
    @SuppressWarnings("unchecked")
    private SystemConfigUtil()
    {
        configs = new LinkedHashMap<String, Object>();
        configs.putAll((Map)SpringContextUtil.getBean("profileConfigMap"));
        configs.putAll((Map)SpringContextUtil.getBean("publicProfileConfigMap"));
    };
    
    private static class Handler
    {
        static SystemConfigUtil handler = new SystemConfigUtil();
    }
    
    public static SystemConfigUtil create()
    {
        return Handler.handler;
    }
    
    public String getValue(String key){
        
        Object value = configs.get(key);
        
        if(value == null) return null;
        
        if(value instanceof String) return value.toString();
        
        if(value instanceof SystemConfigBean){
            //做出数据库处理
            
        }
        
        return null;
        
    }
}
